<!-- 审核投标人 -->
<script setup>
import {
    Edit,
    Delete
} from '@element-plus/icons-vue'
import { ref,computed} from 'vue'
import { someTendererInfo,checkTendererInfo,electTendererInfo } from '@/api/tendererInfo.js'
import { ElMessage } from 'element-plus'


const TendererData = ref([])

const allInfo = async () => {
  let result = await someTendererInfo()
  TendererData.value = result.data
}

allInfo()

// 分页状态
const currentPage = ref(1); // 当前页
const pageSize = ref(10);    // 每页显示的数据量


// 计算当前页展示的数据
const currentPageData = computed(() => {
  const start = (currentPage.value - 1) * pageSize.value;
  const end = start + pageSize.value;
  return TendererData.value.slice(start, end);
});

// 分页切换处理
const handlePageChange = (page) => {
  currentPage.value = page;
};

const handleApprove=async (row)=>{
        // 处理通过操作
        await checkTendererInfo(row.tenderProjectNo);
        ElMessage.success('审批通过')
        allInfo()
    }
const handleReject=async (row)=>{
        // 处理打回操作
        await electTendererInfo(row.tenderProjectNo);
        ElMessage.success('打回成功')
        allInfo()
    }

</script>

<template>
    <el-card class="page-container">
        <template #header>
            <div class="header">
                <span>投标审核</span>
            </div>
        </template>
        <el-table :data="currentPageData" style="width: 100%">
            <el-table-column label="编号" prop="tenderProjectNo"></el-table-column>
            <el-table-column label="药品名称" prop="drugName"></el-table-column>
            <el-table-column label="制药单位" prop="manufacturer"></el-table-column>
            <el-table-column label="包装要求" prop="packagingReq"></el-table-column>
            <el-table-column label="总量"  prop="totalNumber"></el-table-column>
            <el-table-column label="截止日期" prop="tenderDeadline"></el-table-column>
            <el-table-column label="保证金" prop="bidDeposit"></el-table-column>
            <el-table-column label="操作" width="150">
                <template #default="{ row }">
                    <el-button @click="handleApprove(row)" circle plain type="success">通过</el-button>
                    <el-button @click="handleReject(row)" circle plain type="danger">打回</el-button>
                </template>
            </el-table-column>
            <template #empty>
                <el-empty description="没有数据" />
            </template>
        </el-table>
                            <!-- 分页组件 -->
                            <el-pagination
                background
                layout="prev, pager, next"
                :total="TendererData.length"
                :current-page="currentPage"
                :page-size="pageSize"
                @current-change="handlePageChange" />
    </el-card>
</template>

<style lang="scss" scoped>
.page-container {
    min-height: 100%;
    width: 95%; /* 设置为宽一些 */
    max-width: 1500px; /* 最大宽度限制 */
    margin: 0 auto; /* 居中对齐 */
    box-sizing: border-box;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 调整表格内边距和单元格宽度 */
.el-table {
    margin-top: 20px;
    padding: 10px;
}

.el-table-column {
    padding: 8px 10px;
}

</style>
